<!DOCTYPE html>
<html>
<head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<style type="text/css">
#drager {
	width: 100px;
	height: 100px;
}
</style>
<script>
    /*$(document).ready(function() {
    $("#draggable").draggable();
    });*/
    </script>
 <script type="text/javascript">
$(document).ready(function(){
	$("#drager").draggable();
    
    var moving = false, offset = { x: 0, y: 0 };
    $(document).mouseup(function(e) {
        moving = false;
		//alert(offset.x);
		//alert(offset.y);
    });
    $("#drager").mousedown(function(e) {
        e.preventDefault();
        moving = true;
        offset.y = (e.pageY - $("#drager")[0].offsetTop);
        offset.x = (e.pageX - $("#drager")[0].offsetLeft);
		
			
    });
    $(document).mousemove(function(e) {
        if(moving) {
            var o = {
                x: (e.pageX - offset.x) + 'px',
                y: (e.pageY - offset.y) + 'px'
            }
            $("#drager")[0].style.left = o.x;
            $("#drager")[0].style.top = o.y;
			
			
        }
    });
});

</script>   
</head>
<body >
Điền Vào Chỗ Trống
Vị Trí: ____
Vị Trí: <div id="something"></div>
<div id="drager" style="border:solid 1px #993399">Drag me</div>
<script>
myPos = findPos(document.getElementById('something'))
x = myPos[0]
y = myPos[1]
//alert(x +':'+ y);

function findPos(obj) {

var curleft = curtop = 0;
if (obj.offsetParent) {
        curleft = obj.offsetLeft
        curtop = obj.offsetTop
        while (obj = obj.offsetParent) {
                curleft += obj.offsetLeft
                curtop += obj.offsetTop
        }
}
return [curleft,curtop];

}
</script>
</body>
</html>